/*
 * @Description: 底部弹出选择框 BottomSheetWidget
 * @version: 
 * @Company: 
 * @Author: ZhengZhuang
 * @Date: 2019-08-23 16:25:49
 * @LastEditors: ZhengZhuang
 * @LastEditTime: 2019-08-23 17:33:01
 */

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

Future openModalBottomSheet(
    context, modalTitle, List<Map> modalList, defaultNum) async {
  final option = await showModalBottomSheet(
    context: context,
    builder: (BuildContext context) {
      return Container(
        height: ScreenUtil().setWidth(450.0),
        child: Column(
          children: <Widget>[
            Container(
              height: ScreenUtil().setWidth(90.0),
              width: ScreenUtil().setWidth(750.0),
              alignment: Alignment.center,
              decoration: BoxDecoration(
                color: Colors.white,
                boxShadow: <BoxShadow>[
                  BoxShadow(
                    color: Colors.black26,
                    blurRadius: 2.0,
                  ),
                ],
              ),
              child: Row(
                children: <Widget>[
                  // Text('取消'),
                  Expanded(
                    child: Container(
                      alignment: Alignment.center,
                      child: Text(modalTitle),
                    ),
                  ),
                  // Text('确定'),
                ],
              ),
            ),
            ListView(
              shrinkWrap: true,
              children: modalList.map<Widget>((item) {
                return ListTile(
                  title: Text(
                    item['name'],
                    style: TextStyle(
                        color: defaultNum == item['name']
                            ? Color(0xff3FB956)
                            : Colors.black,
                        fontSize: ScreenUtil().setSp(32)),
                  ),
                  onTap: () {
                    Navigator.pop(context, item['name']);
                  },
                );
              }).toList(),
            ),
          ],
        ),
      );
    },
  );
  return option;
}
